import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';

class _t {
    id?: number
    erpWarehouseAreas?: []
    warehouses?: []
}

@Injectable({
    providedIn: 'root'
})
export class MrpManageService {

    private erpUrl: string = "/api/erpWarehouse";
    private mrpUrl: string = "/api/erpWarehouse/warehouse";
    private areaUrl: string = "/api/erpWarehouse/area";

    public detailData: _t = {};

    constructor(
        private http: HttpClient
    ) { }

    apiErpList(data): Observable<any> {
        let _dataJson = {
            params: {
                ...data,
                page: data.page - 1
            }
        }
        return this.http.get(this.erpUrl, _dataJson)
    }
    apiMrpList(data): Observable<any> {
        let _dataJson = {
            params: {
                ...data
            }
        }
        return this.http.get(this.mrpUrl, _dataJson)
    }
    apiHouseSave(data): Observable<any> {
        let _dataJson = {
            ...data
        }
        return this.http.post(this.erpUrl, _dataJson)
    }
    apiHouseDelete(data): Observable<any> {
        let _dataJson = {
            headers: new HttpHeaders({
                'Content-Type': 'application/json',
            }),
            body: data
        }
        return this.http.delete(this.erpUrl, _dataJson);
    }
    apiAreaSave(data): Observable<any> {
        let _dataJson = {
            ...data
        }
        return this.http.post(this.areaUrl, _dataJson);
    }
    apiAreaDelete(data):Observable<any>{
        let _dataJson = {
            headers : new HttpHeaders({
                'Content-Type' : 'application/json'
            }),
            body : data
        }
        return this.http.delete(this.areaUrl, _dataJson);
    }
}
